package com.varian.system.client;

import com.varian.system.dto.UserDetailDTO;
import com.varian.system.remote.SysUserRemote;
import com.varian.system.service.ISysUserService;
import com.varian.tool.contant.VarianConstant;
import com.varian.tool.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ben
 * @since 2024/7/1
 */
@PermitAll
@RequiredArgsConstructor
@Tag(name = "用户服务")
@RestController
@RequestMapping(VarianConstant.FEIGN_PREFIX_PATH)
public class SysUserClient implements SysUserRemote {

    private final ISysUserService userService;

    @Override
    @Validated
    @Operation(summary = "根据用户名查询用户信息")
    @GetMapping(GET_USER_BY_USERNAME)
    public R<UserDetailDTO> getUserByUsername(@NotBlank(message = "用户名不能为空") @RequestParam("username") String username) {
        return R.data(userService.getUserByUsername(username));
    }
}
